﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Create</title>
    <link href="~/Plugins/layui/css/layui.css" rel="stylesheet" />
    <link href="~/Plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
</head>
<body>
    <div style="margin: 15px;">
        <form class="layui-form" id="add">
            @Html.AntiForgeryToken()
            <div class="layui-form-item">
                <label class="layui-form-label">名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" placeholder="请输入名称" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">打开方式</label>
                <div class="layui-input-inline">
                    <select name="target" lay-verify="required">
                        <option value="_self">本页面</option>
                        <option value="_blank">新页面</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">排序值</label>
                <div class="layui-input-inline">
                    <input type="number" name="sort" required lay-verify="required" value="0" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">值越高越靠前</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">是否启用</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="isEnable" checked value="true" lay-skin="switch">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">描述</label>
                <div class="layui-input-block">
                    <textarea name="description" placeholder="请输入描述信息" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo"><i class="fa fa-save"></i> 立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    <a href="@Url.Action("Index","Home")" style="padding-left:15px;">返回列表</a>
                </div>
            </div>
        </form>
    </div>
    <script src="~/Plugins/layui/layui.js"></script>
    <script>
        //Demo
        layui.config({
            base: '../../Plugins/ba/js/',
            v: new Date().getTime()
        }).use(['form', 'baajax', 'layer'], function () {
            var form = layui.form(),
                $ = layui.jquery,
                layerTips = parent.layer === undefined ? layui.layer : parent.layer, //获取父窗口的layer对象
                layer = layui.layer, //获取当前窗口的layer对象
                baajax = layui.baajax;



            //监听提交
            form.on('submit(formDemo)', function (data) {
                baajax.post('@Url.Action("Create","Home")', data.field, function (res) {
                    layerTips.msg(res.msg);
                    if (res.rel) {
                        location.href = '@Url.Action("Index","Home")';
                    }
                });
                return false;
            });

        });
    </script>
</body>
</html>
